﻿using CPPEI.Coolzon.Common;
using CPPEI.Coolzon.UI.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Visifire.Charts;
using Visifire.Commons;

namespace CPPEI.Coolzon.UI.DataPartLib
{
    /// <summary>
    /// Interaction logic for DataChartPie.xaml
    /// </summary>
    [XPartIcon("pack://application:,,,/CPPEI.Coolzon.UI.DataPartLib;component/Images/PartIcons/饼图.png")]
    [XPart("ChartPie", "饼图")]
    [System.ComponentModel.DisplayName("饼图")]
    public partial class DataChartPie : DataChartBase
    {
        public DataChartPie()
        {
            DataPointLabelEnabled = true;
            XStartAngle = 30;
            InitializeComponent();
        }

        protected override Chart GetChart()
        {
            return _ctlChart;
        }
        protected override RenderAs GetRender(string dataSeriesId)
        {
            return RenderAs.Pie;
        }
        protected override void ApplyChartColorPlate(Chart chart, ColorPlate colorPlate)
        {
            if (chart.Series != null && chart.Series.Count > 0)
            {
                foreach (var dataSerie in chart.Series)
                {
                    if (dataSerie.DataPoints != null)
                    {
                        for (int i = 0; i < dataSerie.DataPoints.Count; i++)
                        {
                            dataSerie.DataPoints[i].Color = colorPlate.GetColor(i);
                        }
                    }
                }
            }
        }
    }
}
